//
//  XJRightCollectionViewCell.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/5/10.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJRightCollectionViewCell.h"
// Model
#import "XJRightCollectionModel.h"

@interface XJRightCollectionViewCell()
@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *nameLb;

@end

@implementation XJRightCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubViews];
    }
    return self;
}

- (void)setupSubViews {
    self.imageV = [UIImageView new];
    [self.contentView addSubview:self.imageV];
    
//    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, self.frame.size.width - 4, self.frame.size.width - 4)];

//CGRectMake(2, self.frame.size.width + 2, self.frame.size.width - 4, 20)]
    self.nameLb = [UILabel new];
//    self.nameLb.backgroundColor = [UIColor redColor];
    
    self.nameLb.font = [UIFont systemFontOfSize:13.0];
    self.nameLb.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.nameLb];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    CGFloat s_w = self.frame.size.width;
//    self.imageV.frame = CGRectMake(2, 2, s_w-4, s_w-4);
//    self.nameLb.frame = CGRectMake(2, s_w+2, s_w-4, 20);
    
    self.imageV.sd_layout.topSpaceToView(self.contentView, ADAPTHeight(10)).centerXEqualToView(self.contentView).widthIs(ADAPTWidth(50)).heightIs(ADAPTWidth(50));
    self.nameLb.sd_layout.topSpaceToView(self.imageV, 5).centerXEqualToView(self.imageV).widthIs(s_w*0.8).heightIs(ADAPTWidth(20));
}


#pragma mark - setter方法 赋值
- (void)setClvModel:(XJRightCollectionModel *)clvModel {
    _clvModel = clvModel;
    
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:clvModel.cover] placeholderImage:nil];
    
    self.nameLb.text = clvModel.name;
}

@end
